﻿using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;

namespace WFL.Windows
{
    [StructLayout(LayoutKind.Sequential)]
    public struct RECT : IEquatable<RECT>
    {
        public int Left;
        public int Top;
        public int Right;
        public int Bottom;

        public int Width
        {
            get { return Right - Left; }
        }

        public int Height
        {
            get { return Bottom - Top; }
        }

        public override bool Equals(object obj)
        {
            if (obj is RECT)
            {
                return Equals((RECT)obj);
            }
            else
            {
                return false;
            }
        }

        public override int GetHashCode()
        {
            return (((this.Left ^ ((this.Top << 13) | (this.Top >> 0x13))) ^ ((this.Right << 0x1a) | (this.Right >> 6))) ^ ((this.Bottom << 7) | (this.Bottom >> 0x19)));
        }


        #region IEquatable<RECT> 成员

        public bool Equals(RECT other)
        {
            return this.Left == other.Left
                    && this.Top == other.Top
                    && this.Right == other.Right
                    && this.Bottom == other.Bottom;
        }

        #endregion

    }
}
